package com.example.config;


import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @author ghy
* @date 2025/09/09
* @description Minio配置类
*/
@Configuration
@ConfigurationProperties(prefix = "minio")
@Data
public class MinioConfig {
    // MinIO服务器地址
    private String endpoint;
    // MinIO访问密钥（账号）
    private String accessKey;
    // MinIO私密密钥（密码）
    private String secretKey;
    // 默认存储桶名称
    private String bucketName;

    /**
    * 创建MinioClient对象
     *
    * @return MinioClient对象
    */
    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                // MinIO服务器地址
                .endpoint(endpoint)
                // MinIO访问密钥（账号）, 私密密钥（密码）
                .credentials(accessKey, secretKey)
                // 创建MinioClient对象
                .build();
    }

    /*
    * Getter and Setter
    * */

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }
}
